package com.iotmonitor.iot.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import com.iotmonitor.common.core.annotation.Excel;
import com.iotmonitor.common.core.web.domain.BaseEntity;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * 报警配置对象 tb_alarm
 * 
 * @author ruoyi
 * @date 2023-08-11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TbAlarm extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** id */
    @NotBlank(message = "报警名称长度不能为空", groups = {TbAlarm.Update.class})
    private Long id;

    /** 报警名称 */
    @Excel(name = "报警名称")
    @NotBlank(message = "报警名称长度不能为空", groups = {TbAlarm.Create.class})
    @Size(min = 0, max = 100, message = "报警名称长度不能超过100个字符", groups = {TbAlarm.Create.class})
    private String name;

    /** 指标id */
    @Excel(name = "指标id")
    private Long quotaId;

    /** 运算符 */
    @Excel(name = "运算符")
    @NotBlank(message = "运算符不能为空", groups = {TbAlarm.Create.class})
    private String operator;

    /** 报警阈值 */
    @Excel(name = "报警阈值")
    @Range(max = 999999999, min = -999999999, message = "必须在[-999999999,999999999]区间内", groups = {TbAlarm.Create.class, TbAlarm.Update.class})
    private Long threshold;

    /** 报警级别  1一般 2严重 */
    @Excel(name = "报警级别  1一般 2严重")
    @Min(value = 1, message = "必须大于等于1", groups = {TbAlarm.Create.class, TbAlarm.Update.class})
    @Max(value = 2, message = "必须小于等于2", groups = {TbAlarm.Create.class, TbAlarm.Update.class})
    private Integer level;

    /** 沉默周期（分钟） */
    @Excel(name = "沉默周期", readConverterExp = "分=钟")
    private Integer cycle;

    /** web钩子 */
    @Excel(name = "web钩子")
    private String webhook;

    private TbQuota tbQuota;

    public TbAlarm(String name) {
        this.name = name;
    }
}
